<include file="Public:top" />
<!--头部 end-->

<script type="text/javascript" src="__PUBLIC__/js/ajaxfileupload.js"></script>

<include file="Public:menu" />
 <!--菜单 end-->
 
    <form action="" method="post" id="myform">
            

               <div class="form-group">
                <div class="label"><label for="readme">内容</label></div>
                <div class="field">
                    <textarea  name="cmp_content" id="editor" rows="25" cols="160" placeholder="请填写维护说明" data-validate="required:请填写维护说明">{$result.cmp_content}</textarea>
                     
                  </div>
                </div>
                    <div class="form-group">
                    <div class="label"><label for="title">code</label></div>
                    <div class="field">
                        <input type="number" class="input"  name="code" size="20" value="{$result.code}" style="width:20%;" />
                    </div>
                    <p>0:停止更新；1:成功</p>
                </div>
                <div class="form-group">
                    <div class="label"><label for="title">时间</label></div>
                    <div class="field">
                        <input type="text" class="input"  name="add_time" size="20" value="{$result.add_time}"  style="width:20%;" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="label"><label for="title">备注</label></div>
                    <div class="field">
                        <textarea class="input" name="cmp_img" rows="5" cols="50" >{$result.cmp_img}</textarea>
                    </div>
                </div>



                 <input type="hidden" name="cmp_id" value="{$result.cmp_id}">
                         <div class="form-button" align="center"><button class="button bg-main" id="sure" type="submit">提交</button></div>
                           
                </form>
            </div>
        </div>

    </div>
    <!--/main-->
</div>
 <include file="Public:box" /> 
 <!--底部 end-->
<script>
        //异步表单提交
        $('#sure').click(function(){

            $.post('/console/Intro/doUpdate',$('form').serialize(),function(data){

                if ( data.status )
                {
                    layer.alert(data.info, 1);

                    //刷新当前页
                    location.href = "";
                }
                else
                {

                    layer.alert(data.info);

                }

            },'json');

            return false;

        })

        

        //异步图片上传
        $('body').on('change','.upload',function(){

            var _this = $(this);

            var id = _this.attr('id');

            var div = _this.parent().parent().parent().next('div').children('img');

            var input = _this.parent().parent().parent().next('div').children('input');

            $.ajaxFileUpload
            (
                {
                    url:'/console/Intro/uploadImg',
                    secureuri:false,
                    fileElementId:id,
                    dataType: 'json',
                    success: function (data)
                    {
                        //成功
                        if ( data.status )
                        {
                            div.attr('src', data.path);
                            input.attr('value',data.path);
                        }
                        //失败
                        else
                        {
                            layer.alert(data.info);
                        }

                    }
                }
            )


        })
</script>